package com.igeekhome.ccs.controller;

import com.igeekhome.ccs.biz.ICustomerServiceGroupBiz;
import com.igeekhome.ccs.entity.CustomerService;
import com.igeekhome.ccs.entity.CustomerServiceGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

@Controller
@RequestMapping("/csgroup")
public class CustomerServiceGroupController {
    @Autowired
    private ICustomerServiceGroupBiz biz;
//👇zyh---------------------------------------------------------------------------
    /**
     * 对外提供查询客服组所有信息
     */
    @GetMapping("/query")
    public @ResponseBody
    List<CustomerServiceGroup>  query() {
        return  biz.query();
    }

    /**
     * 通过客服组名获取对应客服信息
     */
    @GetMapping("/queryCsInfoByGroupId")
    public @ResponseBody
    List<CustomerService> queryCsInfoByGroupId(@RequestParam int groupId) {
        return biz.queryCsInfoByGroupId(groupId);
    }

    /**
     * 传入搜索字符串返回客服组对象
     */
    @GetMapping("/queryCsgByString")
    public @ResponseBody
    List<CustomerServiceGroup> queryCsgByString(@RequestParam String str) {
        return biz.matchCsgwithString(str);
    }

    /**
     * 传入id删除单个客服组
     */
    @DeleteMapping("/deleteCsgById")
    public  @ResponseBody
    void deleteCsgById(@RequestParam int csgId){
        biz.deleteCsgById(csgId);
    }

    /**
     * 传入list(id)批量删除客服组
     */
    @DeleteMapping("/deleteCsgByList")
    public @ResponseBody
    void deleteCsgByList(List<Integer> list){
        biz.deleteCsgByList(list);
    }

    /**
     * 新增客服组
     */
    @PostMapping("/createNewCsg")
    public @ResponseBody
    int createNewCsg(@RequestParam String str) throws ParseException { biz.createNewCsg(str);return 0; }

    /**
     * 编辑客服组
     */
    @PostMapping("/updateCsg")
    public @ResponseBody
    int updateCsg(String str,CustomerServiceGroup customerServiceGroup) throws ParseException { biz.updateCsg(str,customerServiceGroup);return 0; }

//👆zyh-------------------------------------------------------
}